#define _CRT_SECURE_NO_WARNINGS
#include"Heap.h"

int main()
{
	HP hp;
	HeaPInit(&hp);
	HeaPPush(&hp, 4);
	HeaPPush(&hp, 18);
	HeaPPush(&hp, 42);
	HeaPPush(&hp, 12);
	HeaPPush(&hp, 21);
	HeaPPush(&hp, 3);
	HeaPPush(&hp, 5);
	HeaPPush(&hp, 5);
	HeaPPush(&hp, 50);
	HeaPPush(&hp, 5);
	HeaPPush(&hp, 5);
	HeaPPush(&hp, 15);
	HeaPPush(&hp, 5);
	HeaPPush(&hp, 45);
	HeaPPush(&hp, 5);

	int k = 0;
	scanf("%d", &k);
	while (!HeaPEmpty(&hp) && k--)
	{
		printf("%d ", HeaPTop(&hp));
		HeaPPop(&hp);
	}
	printf("\n");

	return 0;
}